<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>用户编辑</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
</head>
<body>

<div class="layui-form" lay-filter="user-edit-form" id="user-edit-form"
     style="padding: 20px 0 0 0;">
    <input type="hidden" id="roleId" value="${roleId!}">
    <div class="layui-form-item">
        <div class="layui-input-inline">
            <input type="hidden" id="userId" name="id" value="${userId!0}" readonly="readonly"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">用户名</label>
        <div class="layui-input-inline">
            <input type="text" name="name" value="${name!}" lay-verify="required" placeholder="请输入用户名"
                   autocomplete="off"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">手机号码</label>
        <div class="layui-input-inline">
            <input type="text" name="phone" lay-verify="phone" value="${phone!}" placeholder=" 请输入号码" autocomplete="off"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">角色</label>
        <div class="layui-input-inline">
            <select id="edit_role_selector" name="roleId">
            </select>
        </div>
    </div>
    <div class="layui-form-item layui-hide">
        <input type="button" lay-submit lay-filter="user-edit-submit" id="user-edit-submit" value="确认">
    </div>
</div>

<script src="/layuiadmin/layui/layui.js"></script>
<script src="/assets/js/common.js"></script>

<script>
    layui.config({
        base: '../../../layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form'], function () {
        var $ = layui.$, form = layui.form
        $.get('/role/list', function (res) {
            var roleList = res.data;
            for (var i = 0; i < roleList.length; i++) {
                $('#edit_role_selector').append('<option value=' + roleList[i].id + '>' + roleList[i].name + '</option>');
            }
            var roleId = $('#roleId').val();
            if (!isNull(roleId)) {
                $("#edit_role_selector").val(roleId);
            }
            form.render('select');
        });
    })
</script>
</body>
</html>